import request from '@/utils/request'

// 获取销毁申请表单初始列表
export function getArchiveList(query) {
    return request({
        url: '/archive/destroyKu/carlist',
        method: 'get',
        params: query
    })
}
// 删除销毁申请单中的档案数据
export function delArchiveFormSave(data) {
    return request({
        url: '/archive/destroyKu/delCar',
        method: 'post',
        data:data
    })
}
// 提交销毁申请单
export function submit(data) {
    return request({
        url: '/archive/destroyKu/addDestroy',
        method: 'POST',
        data: data
    })
}

//获取人员树接口
export function deptUserTree(query) {
    return request({
        url: '/system/user/deptUserTreeNoDateScope',
        method: 'GET',
        params: query
    })
}

export function roleUserTree(query) {
    return request({
        url: '/system/user/roleUserTreeNoDateScope',
        method: 'GET',
        params: query
    })
}

// 获取流程类型
export function getProcessType() {
    return request({
        url: '/activiti/activitiApiController/getProcessKeyName',
        method: 'get'
    })
}

// 获取task对应流程审批信息
export function getProcessDate(id) {
    return request({
        url: '/activiti/activitiApiController/getProcessDate/'+ id,
        method: 'get'
    })
}


// 查询归档待办事项
export function taskList(query) {
    return request({
        url: '/activiti/workflowArchiveBorrow/taskList',
        method: 'get',
        params: query
    })
}

// 单个同意、不同意
export function formDataSave(data) {
    return request({
        url: '/activiti/task/formDataSave/'+ data.id,
        method: 'post',
        data: data
    })
}

// 批量同意/不同意
export function formDataSaveAll(data) {
    return request({
        url: '/activiti/task/formDataSaveAll/'+ data.id,
        method: 'post',
        data: data
    })
}

// 查询归档已办事项
export function taskHistoryList(query) {
    return request({
        url: '/activiti/workflowArchiveBorrow/taskHistoryList',
        method: 'get',
        params: query
    })
}

// 查看档案数据
export function getArchiveInfo(data) {
    return request({
        url: '/archive/archiveFormSave/getArchiveInfo?level=' + data.level + '&menuId=' + data.menuId,
        method: 'post',
        data: data
    })
}


// 设置流程中单条状态是否同意
export function setArchiveProcessStatusByArchiveId(data) {
    return request({
        url: '/activiti/workflowArchiveSave/setArchiveProcessStatusByArchiveId/'+ data.processId + '/' + data.archiveId + '/' + data.status,
        method: 'put'
    })
}

// 设置流程中单条状态是否同意
export function setBorrowProcessDownloadStatus(data) {
    return request({
        url: '/activiti/workflowArchiveBorrow/setBorrowProcessDownloadStatus/'+ data.processId + '/' + data.downloadNum + '/' + data.allowDownload,
        method: 'put'
    })
}

// 设置流程中单条状态是否同意
export function setBorrowProcessPrintStatus(data) {
    return request({
        url: '/activiti/workflowArchiveBorrow/setBorrowProcessPrintStatus/'+ data.processId + '/' + data.printNum + '/' + data.allowPrint,
        method: 'put'
    })
}

// 设置流程中单条状态是否同意
export function downloadPurchaseRecordForm() {
    return request({
        url: '/archive/archiveBorrowCar/downloadPurchaseRecordForm',
        method: 'get',
        responseType: 'arraybuffer',
    })
}


export function changeAllArchiveState(processId,status) {
    return request({
        url: '/activiti/workflowArchiveSave/changeAllArchiveState/'+ processId  + '/' + status,
        method: 'put'
    })
}

//获取表头
export function getthbytreenodeHeaderList(data) {
    return request({
        url: '/archive/wjzl/getthbytreenode',
        method: 'POST',
        data: data
    })
}

// 通过categoryId和docId获取电子文件页数
export function getPageCount(data) {
    return request({
        url: '/archive/archiveBorrow/getPageCount/'+ data.categoryId + '/' + data.docId,
        method: 'POST',
    })
}

// 通过YqdaBorrowItemPage的borrow_id和da_id、category_id判断YqdaBorrowItemPage表中是否已有数据，如果有则返回，没有则插入
export function getYqdaBorrowItemPage(data) {
    return request({
        url: '/archive/archiveBorrow/getYqdaBorrowItemPage/'+ data.borrowId + '/' + data.daId + '/' + data.categoryId + '/' + data.docId,
        method: 'POST',
    })
}

// 通过YqdaBorrowItemPage的id修改YqdaBorrowItemPage的page_allow_num字段
export function updateYqdaBorrowItemPage(data) {
    var url=""
    if(data.keyword==null){
        url='/archive/archiveBorrow/updateYqdaBorrowItemPage?id='+ data.id + '&pageAllowNum=' + data.pageAllowNum+"&keyword=";
    }else{
        url='/archive/archiveBorrow/updateYqdaBorrowItemPage?id='+ data.id + '&pageAllowNum=' + data.pageAllowNum+"&keyword="+data.keyword;
    }
    return request({
        url: url,
        method: 'GET',
    })
}

// 获取跳转路径
export function getRouterPath(query) {
    return request({
        url: '/system/menu/getRouterPath',
        method: 'post',
        params: query
    })
}


//判断已办是否显示
export function getNextTaskOptionId(taksId) {
    return request({
        url: '/activiti/task/getNextTaskOption/'+taksId,
        method: 'get',
    })
}
